package com.skt.common_hr.common.puremvc
{
	import com.skt.common_hr.common.AlertMsgVO;
	import com.skt.common_hr.common.AppModuleManager;
	import com.skt.common_hr.common.Messages;
	import com.skt.common_hr.common.StatusMsgVO;
	
	import flash.display.DisplayObject;
	
	import org.puremvc.as3.multicore.interfaces.IFacade;
	import org.puremvc.as3.multicore.patterns.facade.Facade;

	public class CommonFacade extends Facade
	{
		public var moduleKey:String;
		public var bundle:String;
		public var app:DisplayObject;
		
		public function CommonFacade(key:String)
		{
			super(key);
			moduleKey = key;
			bundle = AppModuleManager.getModuleID(key);
		}
		
		// Return the Multiton Facade instance 
		protected function get mainFacade():IFacade
		{
            return instanceMap[ AppModuleManager.MODULE_KEY_MAIN ] as IFacade;
		}
		

		/**
		* View를 초기화 한다.
		*	- View에 기본사항을 출력하고 data를 load
		* @param
		* @return void
		*/
		public function setStatusMessage(msg:String, param:Array=null, type:String="normal"):void
		{
			var msgObj:StatusMsgVO = new StatusMsgVO();
			msgObj.moduleKey = moduleKey;
			msgObj.param = (param==null) ? new Array():param;
			msgObj.message = msg;
			msgObj.type = type;
			mainFacade.sendNotification(Messages.SET_STATUS_MESSAGE, msgObj);
		}
		
		public function showAlertMessage(msg:String, param:Array=null, title:String="", type:String="normal"):void
		{
			var msgObj:AlertMsgVO = new AlertMsgVO();
			msgObj.moduleKey = moduleKey;
			msgObj.param = (param==null) ? new Array():param;
			msgObj.title = title;
			msgObj.message = msg;
			msgObj.type = type;
			mainFacade.sendNotification(Messages.SHOW_ALERT_MESSAGE, msgObj);
		}
	}
}